<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./js/vue.js"></script>
    <title>生命周期尝试</title>
</head>
<body>
    <div id="root">
        <button @click="distroy">点击销毁vm</button>
        <div id="out" style="width: 200px;height: 200px;background-color: #333;"></div>
        <p>{{num}}</p>
    </div>
    <script>
        const vm = new Vue({
            destroyed(){
                console.log('组件已经被销毁')
                console.log(this)
                console.log(this.num)
            },
            methods: {
                distroy(){
                    // console.log(this)
                    this.$destroy()
                }
            },
            data() {
                return {
                    num:1
                }
            },
        }).$mount('#root')

        const div = document.getElementById('out')
        div.onclick = function(){
            console.log(vm.num)
        }
    </script>
</body>
</html>